<?php

namespace App\Jobs\OpenShop;

use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Facades\Artisan;

class PayCsv implements ShouldQueue
{
    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;

    private int $startTime;
    private int $endTime;
    private string $chatId;

    public $timeout = 1800;

    /**
     * 生成开店财务对账单
     *
     * @return void
     */
    public function __construct(int $startTime, int $endTime, string $chatId)
    {
        $this->startTime = $startTime;
        $this->endTime   = $endTime;
        $this->chatId    = $chatId;
    }

    /**
     * Execute the job.
     *
     * @return void
     */
    public function handle()
    {
        Artisan::call("openShop:account-check {$this->startTime} {$this->endTime} {$this->chatId}");
    }
}
